package com.erji.common.utils;

import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SnowFlakeIdGenerator implements IdentifierGenerator {
    private static final Logger LOGGER = LoggerFactory.getLogger(SnowFlakeIdGenerator.class);
    private SnowFlakeSequence snowFlakeSequence;

    public SnowFlakeIdGenerator(SnowFlakeSequence snowFlakeSequence) {
        this.snowFlakeSequence = snowFlakeSequence;
    }

    public Long nextId(Object entity) {
        try {
            return this.snowFlakeSequence.nextId();
        } catch (Exception var3) {
            LOGGER.error(var3.getMessage(), var3);
            return 0L;
        }
    }
}
